import scrapy
from ..items import TxmoviesItem

class TxmsSpider(scrapy.Spider):
    name = 'txms'
    allowed_domains = ['v.qq.com']
    start_urls = ['https://v.qq.com/channel/tv?listpage=1&channel=tv&feature=1']
    feature = 1

    def parse(self, response):
        items = TxmoviesItem()
        lists = response.xpath("//div[@class='list_item']")
        for i in lists:
            items['name'] = i.xpath("./div/a/text()").extract_first()
            items['figure'] = i.xpath("./div/div/text()").extract_first()
            # print(items)
            yield items

        # 执行翻页  不同feature的页面抓取
        # if self.feature < 10:
        #     self.feature += 1
        #     url = 'https://v.qq.com/channel/tv?listpage=1&channel=tv&feature={}'.format(str(self.feature))
        #     yield scrapy.Request(url=url, callback=self.parse)


